import numpy as np
import pandas as pd
from sklearn.cluster import KMeans
import matplotlib.pyplot as plt

pd.set_option('display.max_columns', None)  # 显示所有列，无省略
pd.set_option('display.max_rows', None)     # 显示所有行
pd.set_option('display.max_colwidth', None) # 当列内容过长时也完整显示
pd.set_option('display.width', 2000)        # 设定输出窗口宽度，防止换行断行

data = pd.read_csv('data/order.csv')
x = data.iloc[:,-8:]
wcss = []

for i in range(1,11):
    kmeans = KMeans(n_clusters=i, init='k-means++', random_state=42)
    kmeans.fit(x)
    wcss.append(kmeans.inertia_)

plt.plot(range(1,11), wcss)
plt.show()